package Solution151_175;

import org.junit.Test;

public class Solution151 {
    public String reverseWords(String s) {
        String[] array=s.split(" ");

        StringBuilder builder=new StringBuilder();
        for(int i=array.length-1;i>=0;i--){
            if(array[i]!=null&&!array[i].equals("")){
                builder.append(array[i]);
                builder.append(" ");
            }
        }
        return builder.toString().trim();
    }

@Test
    public void test(){
        String s="a good   example";
        System.out.println(reverseWords(s));
}
}
